/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class CartItem
    {
    
        private String cartItemIdField;

        private String ASINField;

        private String exchangeIdField;

        private String merchantIdField;

        private String sellerIdField;

        private String sellerNicknameField;

        private String quantityField;

        private String titleField;

        private String productGroupField;

        private String listOwnerField;

        private String listTypeField;

        private  CartItemMetaData metaDataField;
        private  Price priceField;
        private  Price itemTotalField;

        /// <summary>
        /// Gets and sets the CartItemId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "CartItemId")]
        public String CartItemId
        {
            get { return this.cartItemIdField ; }
            set { this.cartItemIdField= value; }
        }



        /// <summary>
        /// Sets the CartItemId property
        /// </summary>
        /// <param name="cartItemId">CartItemId property</param>
        /// <returns>this instance</returns>
        public CartItem WithCartItemId(String cartItemId)
        {
            this.cartItemIdField = cartItemId;
            return this;
        }



        /// <summary>
        /// Checks if CartItemId property is set
        /// </summary>
        /// <returns>true if CartItemId property is set</returns>
        public Boolean IsSetCartItemId()
        {
            return  this.cartItemIdField != null;

        }


        /// <summary>
        /// Gets and sets the ASIN property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ASIN")]
        public String ASIN
        {
            get { return this.ASINField ; }
            set { this.ASINField= value; }
        }



        /// <summary>
        /// Sets the ASIN property
        /// </summary>
        /// <param name="ASIN">ASIN property</param>
        /// <returns>this instance</returns>
        public CartItem WithASIN(String ASIN)
        {
            this.ASINField = ASIN;
            return this;
        }



        /// <summary>
        /// Checks if ASIN property is set
        /// </summary>
        /// <returns>true if ASIN property is set</returns>
        public Boolean IsSetASIN()
        {
            return  this.ASINField != null;

        }


        /// <summary>
        /// Gets and sets the ExchangeId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ExchangeId")]
        public String ExchangeId
        {
            get { return this.exchangeIdField ; }
            set { this.exchangeIdField= value; }
        }



        /// <summary>
        /// Sets the ExchangeId property
        /// </summary>
        /// <param name="exchangeId">ExchangeId property</param>
        /// <returns>this instance</returns>
        public CartItem WithExchangeId(String exchangeId)
        {
            this.exchangeIdField = exchangeId;
            return this;
        }



        /// <summary>
        /// Checks if ExchangeId property is set
        /// </summary>
        /// <returns>true if ExchangeId property is set</returns>
        public Boolean IsSetExchangeId()
        {
            return  this.exchangeIdField != null;

        }


        /// <summary>
        /// Gets and sets the MerchantId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "MerchantId")]
        public String MerchantId
        {
            get { return this.merchantIdField ; }
            set { this.merchantIdField= value; }
        }



        /// <summary>
        /// Sets the MerchantId property
        /// </summary>
        /// <param name="merchantId">MerchantId property</param>
        /// <returns>this instance</returns>
        public CartItem WithMerchantId(String merchantId)
        {
            this.merchantIdField = merchantId;
            return this;
        }



        /// <summary>
        /// Checks if MerchantId property is set
        /// </summary>
        /// <returns>true if MerchantId property is set</returns>
        public Boolean IsSetMerchantId()
        {
            return  this.merchantIdField != null;

        }


        /// <summary>
        /// Gets and sets the SellerId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "SellerId")]
        public String SellerId
        {
            get { return this.sellerIdField ; }
            set { this.sellerIdField= value; }
        }



        /// <summary>
        /// Sets the SellerId property
        /// </summary>
        /// <param name="sellerId">SellerId property</param>
        /// <returns>this instance</returns>
        public CartItem WithSellerId(String sellerId)
        {
            this.sellerIdField = sellerId;
            return this;
        }



        /// <summary>
        /// Checks if SellerId property is set
        /// </summary>
        /// <returns>true if SellerId property is set</returns>
        public Boolean IsSetSellerId()
        {
            return  this.sellerIdField != null;

        }


        /// <summary>
        /// Gets and sets the SellerNickname property.
        /// </summary>
        [XmlElementAttribute(ElementName = "SellerNickname")]
        public String SellerNickname
        {
            get { return this.sellerNicknameField ; }
            set { this.sellerNicknameField= value; }
        }



        /// <summary>
        /// Sets the SellerNickname property
        /// </summary>
        /// <param name="sellerNickname">SellerNickname property</param>
        /// <returns>this instance</returns>
        public CartItem WithSellerNickname(String sellerNickname)
        {
            this.sellerNicknameField = sellerNickname;
            return this;
        }



        /// <summary>
        /// Checks if SellerNickname property is set
        /// </summary>
        /// <returns>true if SellerNickname property is set</returns>
        public Boolean IsSetSellerNickname()
        {
            return  this.sellerNicknameField != null;

        }


        /// <summary>
        /// Gets and sets the Quantity property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Quantity")]
        public String Quantity
        {
            get { return this.quantityField ; }
            set { this.quantityField= value; }
        }



        /// <summary>
        /// Sets the Quantity property
        /// </summary>
        /// <param name="quantity">Quantity property</param>
        /// <returns>this instance</returns>
        public CartItem WithQuantity(String quantity)
        {
            this.quantityField = quantity;
            return this;
        }



        /// <summary>
        /// Checks if Quantity property is set
        /// </summary>
        /// <returns>true if Quantity property is set</returns>
        public Boolean IsSetQuantity()
        {
            return  this.quantityField != null;

        }


        /// <summary>
        /// Gets and sets the Title property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Title")]
        public String Title
        {
            get { return this.titleField ; }
            set { this.titleField= value; }
        }



        /// <summary>
        /// Sets the Title property
        /// </summary>
        /// <param name="title">Title property</param>
        /// <returns>this instance</returns>
        public CartItem WithTitle(String title)
        {
            this.titleField = title;
            return this;
        }



        /// <summary>
        /// Checks if Title property is set
        /// </summary>
        /// <returns>true if Title property is set</returns>
        public Boolean IsSetTitle()
        {
            return  this.titleField != null;

        }


        /// <summary>
        /// Gets and sets the ProductGroup property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ProductGroup")]
        public String ProductGroup
        {
            get { return this.productGroupField ; }
            set { this.productGroupField= value; }
        }



        /// <summary>
        /// Sets the ProductGroup property
        /// </summary>
        /// <param name="productGroup">ProductGroup property</param>
        /// <returns>this instance</returns>
        public CartItem WithProductGroup(String productGroup)
        {
            this.productGroupField = productGroup;
            return this;
        }



        /// <summary>
        /// Checks if ProductGroup property is set
        /// </summary>
        /// <returns>true if ProductGroup property is set</returns>
        public Boolean IsSetProductGroup()
        {
            return  this.productGroupField != null;

        }


        /// <summary>
        /// Gets and sets the ListOwner property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ListOwner")]
        public String ListOwner
        {
            get { return this.listOwnerField ; }
            set { this.listOwnerField= value; }
        }



        /// <summary>
        /// Sets the ListOwner property
        /// </summary>
        /// <param name="listOwner">ListOwner property</param>
        /// <returns>this instance</returns>
        public CartItem WithListOwner(String listOwner)
        {
            this.listOwnerField = listOwner;
            return this;
        }



        /// <summary>
        /// Checks if ListOwner property is set
        /// </summary>
        /// <returns>true if ListOwner property is set</returns>
        public Boolean IsSetListOwner()
        {
            return  this.listOwnerField != null;

        }


        /// <summary>
        /// Gets and sets the ListType property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ListType")]
        public String ListType
        {
            get { return this.listTypeField ; }
            set { this.listTypeField= value; }
        }



        /// <summary>
        /// Sets the ListType property
        /// </summary>
        /// <param name="listType">ListType property</param>
        /// <returns>this instance</returns>
        public CartItem WithListType(String listType)
        {
            this.listTypeField = listType;
            return this;
        }



        /// <summary>
        /// Checks if ListType property is set
        /// </summary>
        /// <returns>true if ListType property is set</returns>
        public Boolean IsSetListType()
        {
            return  this.listTypeField != null;

        }


        /// <summary>
        /// Gets and sets the MetaData property.
        /// </summary>
        [XmlElementAttribute(ElementName = "MetaData")]
        public CartItemMetaData MetaData
        {
            get { return this.metaDataField ; }
            set { this.metaDataField = value; }
        }



        /// <summary>
        /// Sets the MetaData property
        /// </summary>
        /// <param name="metaData">MetaData property</param>
        /// <returns>this instance</returns>
        public CartItem WithMetaData(CartItemMetaData metaData)
        {
            this.metaDataField = metaData;
            return this;
        }



        /// <summary>
        /// Checks if MetaData property is set
        /// </summary>
        /// <returns>true if MetaData property is set</returns>
        public Boolean IsSetMetaData()
        {
            return this.metaDataField != null;
        }




        /// <summary>
        /// Gets and sets the Price property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Price")]
        public Price Price
        {
            get { return this.priceField ; }
            set { this.priceField = value; }
        }



        /// <summary>
        /// Sets the Price property
        /// </summary>
        /// <param name="price">Price property</param>
        /// <returns>this instance</returns>
        public CartItem WithPrice(Price price)
        {
            this.priceField = price;
            return this;
        }



        /// <summary>
        /// Checks if Price property is set
        /// </summary>
        /// <returns>true if Price property is set</returns>
        public Boolean IsSetPrice()
        {
            return this.priceField != null;
        }




        /// <summary>
        /// Gets and sets the ItemTotal property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ItemTotal")]
        public Price ItemTotal
        {
            get { return this.itemTotalField ; }
            set { this.itemTotalField = value; }
        }



        /// <summary>
        /// Sets the ItemTotal property
        /// </summary>
        /// <param name="itemTotal">ItemTotal property</param>
        /// <returns>this instance</returns>
        public CartItem WithItemTotal(Price itemTotal)
        {
            this.itemTotalField = itemTotal;
            return this;
        }



        /// <summary>
        /// Checks if ItemTotal property is set
        /// </summary>
        /// <returns>true if ItemTotal property is set</returns>
        public Boolean IsSetItemTotal()
        {
            return this.itemTotalField != null;
        }






        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetCartItemId()) {
                xml.Append("<CartItemId>");
                xml.Append(EscapeXML(this.CartItemId));
                xml.Append("</CartItemId>");
            }
            if (IsSetASIN()) {
                xml.Append("<ASIN>");
                xml.Append(EscapeXML(this.ASIN));
                xml.Append("</ASIN>");
            }
            if (IsSetExchangeId()) {
                xml.Append("<ExchangeId>");
                xml.Append(EscapeXML(this.ExchangeId));
                xml.Append("</ExchangeId>");
            }
            if (IsSetMerchantId()) {
                xml.Append("<MerchantId>");
                xml.Append(EscapeXML(this.MerchantId));
                xml.Append("</MerchantId>");
            }
            if (IsSetSellerId()) {
                xml.Append("<SellerId>");
                xml.Append(EscapeXML(this.SellerId));
                xml.Append("</SellerId>");
            }
            if (IsSetSellerNickname()) {
                xml.Append("<SellerNickname>");
                xml.Append(EscapeXML(this.SellerNickname));
                xml.Append("</SellerNickname>");
            }
            if (IsSetQuantity()) {
                xml.Append("<Quantity>");
                xml.Append(EscapeXML(this.Quantity));
                xml.Append("</Quantity>");
            }
            if (IsSetTitle()) {
                xml.Append("<Title>");
                xml.Append(EscapeXML(this.Title));
                xml.Append("</Title>");
            }
            if (IsSetProductGroup()) {
                xml.Append("<ProductGroup>");
                xml.Append(EscapeXML(this.ProductGroup));
                xml.Append("</ProductGroup>");
            }
            if (IsSetListOwner()) {
                xml.Append("<ListOwner>");
                xml.Append(EscapeXML(this.ListOwner));
                xml.Append("</ListOwner>");
            }
            if (IsSetListType()) {
                xml.Append("<ListType>");
                xml.Append(EscapeXML(this.ListType));
                xml.Append("</ListType>");
            }
            if (IsSetMetaData()) {
                CartItemMetaData  metaData = this.MetaData;
                xml.Append("<MetaData>");
                xml.Append(metaData.ToXMLFragment());
                xml.Append("</MetaData>");
            } 
            if (IsSetPrice()) {
                Price  price = this.Price;
                xml.Append("<Price>");
                xml.Append(price.ToXMLFragment());
                xml.Append("</Price>");
            } 
            if (IsSetItemTotal()) {
                Price  itemTotal = this.ItemTotal;
                xml.Append("<ItemTotal>");
                xml.Append(itemTotal.ToXMLFragment());
                xml.Append("</ItemTotal>");
            } 
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}